package com.atguigu.mapreduce.solution;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SolutionReducer extends Reducer<Text, IntWritable, Text, StatBean> {
    private final StatBean stat = new StatBean();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Reducer<Text, IntWritable, Text, StatBean>.Context context) throws IOException, InterruptedException {
        stat.init();
        values.forEach(intWritable -> stat.append(intWritable.get()));
        context.write(key, stat);
    }
}
